package com.sinodata.bsm.common.vo;

import java.text.CollationKey;
import java.text.Collator;
import java.text.RuleBasedCollator;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * PageModuleDef entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "PAGE_MODULE_DEF")
public class PageModuleDef implements java.io.Serializable, Comparable {

    /**
     * 
     */
    private static final long serialVersionUID = 4614996512369883423L;

    // Fields    
    private String jspPage;
    private String title;
    private String pageDetail;
    private String typename;

    // Constructors

    /** default constructor */
    public PageModuleDef() {
    }

    /** minimal constructor */
    public PageModuleDef(String jspPage) {
        this.jspPage = jspPage;
    }

    /** full constructor */
    public PageModuleDef(String jspPage, String title, String pageDetail, String typename) {
        this.jspPage = jspPage;
        this.title = title;
        this.pageDetail = pageDetail;
        this.typename = typename;
    }

    // Property accessors
    @Id
    @Column(name = "JSP_PAGE", unique = true, nullable = false, length = 32)
    public String getJspPage() {
        return this.jspPage;
    }

    public void setJspPage(String jspPage) {
        this.jspPage = jspPage;
    }

    @Column(name = "TITLE", length = 64)
    public String getTitle() {
        return this.title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Column(name = "PAGE_DETAIL", length = 1024)
    public String getPageDetail() {
        return this.pageDetail;
    }

    public void setPageDetail(String pageDetail) {
        this.pageDetail = pageDetail;
    }

    @Column(name = "TYPENAME", length = 64)
    public String getTypename() {
        return this.typename;
    }

    public void setTypename(String typename) {
        this.typename = typename;
    }

    @Override
    public String toString() {
        return "PageModuleDef [jspPage=" + jspPage + ", title=" + title + ", pageDetail=" + pageDetail + ", typename=" + typename + "]";
    }

    @Override
    public int compareTo(Object o) {
        RuleBasedCollator collator = (RuleBasedCollator) Collator.getInstance(java.util.Locale.CHINA);// try testing
        PageModuleDef other = (PageModuleDef) o;
        CollationKey c1 = collator.getCollationKey(this.typename);
        CollationKey c2 = collator.getCollationKey(other.getTypename());

        int cmp = collator.compare(((CollationKey) c1).getSourceString(), ((CollationKey) c2).getSourceString());
        if (cmp == 0) {
            CollationKey c3 = collator.getCollationKey(this.title);
            CollationKey c4 = collator.getCollationKey(other.getTitle());
            return collator.compare(((CollationKey) c3).getSourceString(), ((CollationKey) c4).getSourceString());
        }
        return cmp;
    }

}